/// @file analyser.h
/// @brief Declaration of the Analyser class
/// @date 23/09/2009
/// @author Jérôme Stadelmann, Reds, Heig-vd

#ifndef ANALYSER_H
#define ANALYSER_H

#include <QObject>
#include "sensorplot.h"
#include "OakSensorVisual.h"
#include <qtimer.h>
#include <vector>
#include "serializer.h"

/// The number of channels for every sensor after the timestamp channel
#define SENSOR_CHANNEL_NUMBER       3

/// The number of different profiles supported by the Gui
#define PROFILE_NUMBER              2

/// The number of points used to calculate the fft
#define SAMPLES_SIZE                256 // Has to be a power of 2 !!

/// The binary logarithm of the SAMPLES_SIZE values. Used to speed up the calculations
#define LOG2_SAMPLES_SIZE           8 // Don't forget the binary logarithm of the SAMPLES_SIZE value

/// This class manages all the training and recognition processes
class Analyser : public QObject
{
    Q_OBJECT

public:
    /// Constructor
    Analyser(int fftPoints = 30);

    /// Destructor
   virtual ~Analyser();

    /// Sets a MainWindow as a gui for this object. Will be used to get user commands and to display results
    void    setView(sensorPlot* pView);

    /// Adds a sensor to the system
    void    addSensor(OakSensorVisual* pSensor);



public slots:

    /// get the last buffer value
    void    onPrintAction(sensorPlot::graphData *gData, bool print);

private:

    /// For each sensor, get and log to a file the last samples
    void    logSensorData();




    sensorPlot*         m_pView;
    vector<OakSensorVisual*>  m_sensors;



    int                 m_fftPoints;

    float*              m_pMeans[PROFILE_NUMBER];
    float*              m_pStdDevs[PROFILE_NUMBER];

    Serializer*         m_pLogSerializer;
};

#endif // ANALYSER_H
